from Tkinter import *
from tkMessageBox import *
from svn_interface import *
from commit_ui import CommitUI

class ShelfUI(CommitUI):
  """
  Asks for a commit message AND a shelf branch to 'shelf' to.
  """
  # TODO: generalize beyond Google Code!
  def __init__(self, master, callback):
    self.create_toplevel_window(master, title='Emergency Commit')
    self.add_branch_entry()
    self.add_commit_ui(verb='Shelve')
    self.callback = callback

  def add_branch_entry(self):
    lbl = Label(self.master, text='What name will you give to these shelved changes?', wraplength=300)
    lbl.pack(side=TOP)
    self.branch_entry = Entry(self.master)
    self.branch_entry.pack(side=TOP, fill=X, expand=1)

  def commit(self):
    log_message = self.text.get(1.0, END)
    branch_name = self.branch_entry.get()
    self.master.destroy()
    self.callback(log_message, branch_name)

